package com.example.springtransation.controller;

import com.example.springtransation.service.LogService;
import com.example.springtransation.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-12-31
 * Time: 21:10
 */
@RestController
@RequestMapping("/propaga")
public class PropagationController {
    @Autowired
    private UserService userService;
    @Autowired
    private LogService logService;

    @Transactional(propagation = Propagation.REQUIRED)
    @RequestMapping("/r3")
    public String r3(String name , String password){
        //用户注册
        userService.registryUser(name,password);
        //记录操作日志
        logService.logService(name,"用户注册");
        return "r3";
    }
}
